/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wanhai.itm.util;

import com.wanhai.bizbean.WHL_BizLocal;
import com.wanhai.data.tool.DataSet;
import com.wanhai.util.EjbClient;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.model.SelectItem;
import org.zkoss.zul.ListModelList;

/**
 *
 * @author m2434
 */
public class LoadOption {
    private static LoadOption ourInstance;
    private DataSetService dsService = new DataSetService();
    private static List<SelectItem> ChassisMode;
    
    public static LoadOption getInstance() {
        if (ourInstance==null){
            ourInstance=new LoadOption();
        }
        return ourInstance;
    }
    
    public static ListModelList<SelectItem> getDayOfWeek(){
        ListModelList tempList = new ListModelList();
        
        tempList.add(new SelectItem("1","Sunday"));
        tempList.add(new SelectItem("2","Monday"));
        tempList.add(new SelectItem("3","Tuesday"));
        tempList.add(new SelectItem("4","Wednesday"));
        tempList.add(new SelectItem("5","Thursday"));
        tempList.add(new SelectItem("6","Friday"));
        tempList.add(new SelectItem("7","Saturday"));
        
        return tempList;
    }
    
    public static ListModelList<SelectItem> getYesOrNo(){
        ListModelList tempList = new ListModelList();
        
        tempList.add(new SelectItem("Y","Y"));
        tempList.add(new SelectItem("N","N"));
        
        return tempList;
    }
    
    public List<SelectItem> getChassisMode(){
        
        try{
            if(ChassisMode == null){
                List<SelectItem> tempList = new ListModelList();
                
                StringBuilder sb = new StringBuilder();
                sb.append("SELECT MISC_VALUE AS CHASSIS_MODE, MISC_NAME AS CHASSIS_MODE_DESC\n");
                sb.append("FROM   CUS2060\n");
                sb.append("WHERE  MISC_TYPE = 'CHASSIS_MODE'\n");
                sb.append("ORDER BY MISC_VALUE");

                DataSet ds = dsService.getBizLocal().getMISCData(sb.toString(), new ArrayList(), "java:/OraWhl2DS");
                if (ds != null && ds.getSize() > 0) {
                    for (int i = 0; i < ds.getSize(); i++) {
                        tempList.add(new SelectItem(ds.getValue(i, "CHASSIS_MODE"), ds.getValue(i, "CHASSIS_MODE_DESC")));
                    }
                }
                ChassisMode = tempList;
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        
        return ChassisMode;
    }
    
}
